<!-- build time:Fri Nov 18 2016 13:02:48 GMT+0800 (CST) --><!DOCTYPE HTML><html lang="zh-CN"><head><meta charset="UTF-8"><title>Android Log工具类-爱红旗渠</title><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"><meta name="author" content="Jin"><meta name="keywords" content="Android Log工具类,LogUtils,LogHelper,Log, 爱红旗渠, ihongqiqu, ihongqiqu.com, aihongqiqu"><meta name="description" content="&amp;lt;!-- build time:Fri Nov 18 2016 13:02:32 GMT+0800 (CST) --&amp;gt;工欲善其事，必先利其器。在 Android 开发过程中，相信都会遇到这样的问题：Log 太多，不容易找到自己设置打印的内容找到 Log 但是定位到 Java 源码有不是很方便对 Log 打印需要设置 Tag，大多时候 Tag 就是本类的类名，存在重复的工作发布正式版本需要注释或者关"><meta property="og:type" content="article"><meta property="og:title" content="Android Log工具类"><meta property="og:url" content="http://ihongqiqu.com/2014/10/16/android-log/index.html"><meta property="og:site_name" content="爱红旗渠"><meta property="og:description" content="&amp;lt;!-- build time:Fri Nov 18 2016 13:02:32 GMT+0800 (CST) --&amp;gt;工欲善其事，必先利其器。在 Android 开发过程中，相信都会遇到这样的问题：Log 太多，不容易找到自己设置打印的内容找到 Log 但是定位到 Java 源码有不是很方便对 Log 打印需要设置 Tag，大多时候 Tag 就是本类的类名，存在重复的工作发布正式版本需要注释或者关"><meta property="og:updated_time" content="2016-11-01T14:20:46.000Z"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="Android Log工具类"><meta name="twitter:description" content="&amp;lt;!-- build time:Fri Nov 18 2016 13:02:32 GMT+0800 (CST) --&amp;gt;工欲善其事，必先利其器。在 Android 开发过程中，相信都会遇到这样的问题：Log 太多，不容易找到自己设置打印的内容找到 Log 但是定位到 Java 源码有不是很方便对 Log 打印需要设置 Tag，大多时候 Tag 就是本类的类名，存在重复的工作发布正式版本需要注释或者关"><link rel="alternative" href="/atom.xml" title="爱红旗渠" type="application/atom+xml"><link rel="icon" href="/favicon.ico"><link rel="apple-touch-icon" href="/imgs/myself.jpg"><link rel="apple-touch-icon-precomposed" href="/imgs/myself.jpg"><link rel="stylesheet" href="/css/style.css" type="text/css"></head></html><body><header><div><div id="textlogo"><h1 class="site-name"><a href="/" title="爱红旗渠">爱红旗渠</a></h1><h2 class="blog-motto">Stay hungry, stay foolish.</h2></div><div class="navbar"><a class="navbutton navmobile" href="#" title="菜单"></a></div><nav class="animated"><ul><ul><li><a href="/">首页</a></li><li><a href="/archives">归档</a></li><li><a href="/about">关于</a></li><li><form class="search" action="/search/index.html" method="get" accept-charset="utf-8"><label>Search</label><input type="text" id="search" class="st-default-search-input" maxlength="20" placeholder="Search"></form></li></ul></ul></nav></div></header><div id="container"><div id="main" class="post" itemscope itemprop="blogPost"><article itemprop="articleBody"><header class="article-info clearfix"><h1 itemprop="name"><a href="/2014/10/16/android-log/" title="Android Log工具类" itemprop="url">Android Log工具类</a></h1><p class="article-author">By <a href="/about" title="Jin" target="_blank" itemprop="author">Jin</a></p><p class="article-time"><time datetime="2014-10-16T14:38:12.000Z" itemprop="datePublished">发表于 2014-10-16</time></p></header><div class="article-content"><div id="toc" class="toc-article"><strong class="toc-title">文章目录</strong><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#u6982_u8981"><span class="toc-number">1.</span> <span class="toc-text">概要</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#u51CF_u5C11_u4E00_u4E2A_Log__u53C2_u6570"><span class="toc-number">2.</span> <span class="toc-text">减少一个 Log 参数</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#u8DF3_u8F6C_u5230_u6E90_u4EE3_u7801_Log__u8C03_u7528_u5904"><span class="toc-number">3.</span> <span class="toc-text">跳转到源代码 Log 调用处</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#u5C4F_u853D_u6240_u6709_Log"><span class="toc-number">4.</span> <span class="toc-text">屏蔽所有 Log</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#u4F7F_u7528_u65B9_u6CD5"><span class="toc-number">5.</span> <span class="toc-text">使用方法</span></a></li></ol></div><p>工欲善其事，必先利其器。在 Android 开发过程中，相信都会遇到这样的问题：</p><ul><li>Log 太多，不容易找到自己设置打印的内容</li><li>找到 Log 但是定位到 Java 源码有不是很方便</li><li>对 Log 打印需要设置 Tag，大多时候 Tag 就是本类的类名，存在重复的工作</li><li>发布正式版本需要注释或者关掉很多 Log 开关</li></ul><a id="more"></a><h3 id="u6982_u8981"><a href="#u6982_u8981" class="headerlink" title="概要"></a>概要</h3><p>参考 Android 源码，使用官方的 Log 打印方法（设置Tag），然后再 Eclipse 里面设置过滤标签，这样就可以查看某一个类的 Log 了，但是这样效率比较低下。基于上面的一些问题，我研究实现了一种简单易用的 Log 工具类。我的工具类主要有如下特点：</p><ul><li>减少一个 Log 参数</li><li>调用某些 Log 方法，可以实现跳转到 Java 源代码的功能</li><li>采用此工具类，屏蔽 Log 只需要关闭 Log 总开关即可</li></ul><h3 id="u51CF_u5C11_u4E00_u4E2A_Log__u53C2_u6570"><a href="#u51CF_u5C11_u4E00_u4E2A_Log__u53C2_u6570" class="headerlink" title="减少一个 Log 参数"></a>减少一个 Log 参数</h3><p>实现方法是采用 <code>StackTraceElement</code> 获取调用类的方法，代码如下：</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> String <span class="title">getClassName</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    String result = <span class="string">""</span>;</span><br><span class="line">    StackTraceElement thisMethodStack = (<span class="keyword">new</span> Exception()).getStackTrace()[<span class="number">2</span>];</span><br><span class="line">    result = thisMethodStack.getClassName();</span><br><span class="line">    <span class="keyword">return</span> result;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><h3 id="u8DF3_u8F6C_u5230_u6E90_u4EE3_u7801_Log__u8C03_u7528_u5904"><a href="#u8DF3_u8F6C_u5230_u6E90_u4EE3_u7801_Log__u8C03_u7528_u5904" class="headerlink" title="跳转到源代码 Log 调用处"></a>跳转到源代码 Log 调用处</h3><p>实现双击 Log 跳转到 Java 源代码调用处，实现方法是参考 Android Logcat 错处日志，发现 Eclipse 实现跳转是因为 Log 中有 <code>at MyClassName.MyMethodName(MClassName.java:行数)</code> 。具体见代码：</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span><br><span class="line"> * Realization of double click jump events.</span><br><span class="line"> * </span><br><span class="line"> * <span class="doctag">@return</span></span><br><span class="line"> */</span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> String <span class="title">callMethodAndLine</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    String result = <span class="string">"at "</span>;</span><br><span class="line">    StackTraceElement thisMethodStack = (<span class="keyword">new</span> Exception()).getStackTrace()[<span class="number">2</span>];</span><br><span class="line">    result += thisMethodStack.getClassName() + <span class="string">"."</span>;</span><br><span class="line">    result += thisMethodStack.getMethodName();</span><br><span class="line">    result += <span class="string">"("</span> + thisMethodStack.getFileName();</span><br><span class="line">    result += <span class="string">":"</span> + thisMethodStack.getLineNumber() + <span class="string">")  "</span>;</span><br><span class="line">    <span class="keyword">return</span> result;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><h3 id="u5C4F_u853D_u6240_u6709_Log"><a href="#u5C4F_u853D_u6240_u6709_Log" class="headerlink" title="屏蔽所有 Log"></a>屏蔽所有 Log</h3><p>采用 <a href="https://github.com/jingle1267/android-utils/blob/master/src/com/worthed/util/LogUtils.java" rel="external nofollow" target="_blank">LogUtils</a> 工具类，只需要将此类中<code>DEBUG_LEVEL</code>设置的值大一点。</p><ul><li>如果想要屏蔽所有的 Log 只需要将 <code>DEBUG_LEVEL</code> 设置为 <code>Log.ASSERT</code> 即可。</li><li>如果想要只显示 Error 则只需要将 <code>DEBUG_LEVEL</code> 设置为 <code>Log.WARN</code> 即可。</li><li>如果只想要显示 Error 和 Warn 则将 <code>DEBUG_LEVEL</code> 设置为 <code>Log.INFO</code> 即可。</li></ul><h3 id="u4F7F_u7528_u65B9_u6CD5"><a href="#u4F7F_u7528_u65B9_u6CD5" class="headerlink" title="使用方法"></a>使用方法</h3><p>只需要用 LogUtils 替换掉 Android 系统的 Log 类，并去掉 log 方法的第一个参数，例如：</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">LogUtils.d(Object); <span class="comment">// 次行代码将打印Object类的toString()</span></span><br></pre></td></tr></table></figure><p>无代码无真相，下面是此工具类源码：</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span><br><span class="line"> * Copyright 2014 Zhenguo Jin</span><br><span class="line"> *</span><br><span class="line"> * Licensed under the Apache License, Version 2.0 (the "License");</span><br><span class="line"> * you may not use this file except in compliance with the License.</span><br><span class="line"> * You may obtain a copy of the License at</span><br><span class="line"> *</span><br><span class="line"> *   http://www.apache.org/licenses/LICENSE-2.0</span><br><span class="line"> *</span><br><span class="line"> * Unless required by applicable law or agreed to in writing, software</span><br><span class="line"> * distributed under the License is distributed on an "AS IS" BASIS,</span><br><span class="line"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span><br><span class="line"> * See the License for the specific language governing permissions and</span><br><span class="line"> * limitations under the License.</span><br><span class="line"> */</span></span><br><span class="line"><span class="keyword">package</span> com.worthed.util;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> android.util.Log;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span><br><span class="line"> * This class can replace android.util.Log.</span><br><span class="line"> * </span><br><span class="line"> * <span class="doctag">@author</span> jingle1267@163.com</span><br><span class="line"> * </span><br><span class="line"> * <span class="doctag">@description</span> And you can turn off the log by set DEBUG_LEVEL = Log.ASSERT.</span><br><span class="line"> * </span><br><span class="line"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">LogUtils</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Master switch.To catch error info you need set this value below Log.WARN</span><br><span class="line">     */</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> DEBUG_LEVEL = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * 'System.out' switch.When it is true, you can see the 'System.out' log.</span><br><span class="line">     * Otherwise, you cannot.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">boolean</span> DEBUG_SYSOUT = <span class="keyword">false</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send a &#123;<span class="doctag">@link</span> #VERBOSE&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> obj</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">v</span><span class="params">(Object obj)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.VERBOSE &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String msg = obj != <span class="keyword">null</span> ? obj.toString() : <span class="string">"obj == null"</span>;</span><br><span class="line">            Log.v(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send a &#123;<span class="doctag">@link</span> #DEBUG_LEVEL&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> obj</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">d</span><span class="params">(Object obj)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.DEBUG &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String msg = obj != <span class="keyword">null</span> ? obj.toString() : <span class="string">"obj == null"</span>;</span><br><span class="line">            Log.d(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send an &#123;<span class="doctag">@link</span> #INFO&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> obj</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">i</span><span class="params">(Object obj)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.INFO &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String msg = obj != <span class="keyword">null</span> ? obj.toString() : <span class="string">"obj == null"</span>;</span><br><span class="line">            Log.i(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send a &#123;<span class="doctag">@link</span> #WARN&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> obj</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">w</span><span class="params">(Object obj)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.WARN &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String msg = obj != <span class="keyword">null</span> ? obj.toString() : <span class="string">"obj == null"</span>;</span><br><span class="line">            Log.w(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send an &#123;<span class="doctag">@link</span> #ERROR&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> obj</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">e</span><span class="params">(Object obj)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.ERROR &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String msg = obj != <span class="keyword">null</span> ? obj.toString() : <span class="string">"obj == null"</span>;</span><br><span class="line">            Log.e(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * What a Terrible Failure: Report a condition that should never happen. The</span><br><span class="line">     * error will always be logged at level ASSERT with the call stack.</span><br><span class="line">     * Depending on system configuration, a report may be added to the</span><br><span class="line">     * &#123;<span class="doctag">@link</span> android.os.DropBoxManager&#125; and/or the process may be terminated</span><br><span class="line">     * immediately with an error dialog.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> obj</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">wtf</span><span class="params">(Object obj)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.ASSERT &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String msg = obj != <span class="keyword">null</span> ? obj.toString() : <span class="string">"obj == null"</span>;</span><br><span class="line">            Log.wtf(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send a &#123;<span class="doctag">@link</span> #VERBOSE&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> tag</span><br><span class="line">     *            Used to identify the source of a log message. It usually</span><br><span class="line">     *            identifies the class or activity where the log call occurs.</span><br><span class="line">     * <span class="doctag">@param</span> msg</span><br><span class="line">     *            The message you would like logged.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">v</span><span class="params">(String tag, String msg)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.VERBOSE &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            Log.v(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send a &#123;<span class="doctag">@link</span> #DEBUG_LEVEL&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> tag</span><br><span class="line">     *            Used to identify the source of a log message. It usually</span><br><span class="line">     *            identifies the class or activity where the log call occurs.</span><br><span class="line">     * <span class="doctag">@param</span> msg</span><br><span class="line">     *            The message you would like logged.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">d</span><span class="params">(String tag, String msg)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.DEBUG &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            Log.d(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send an &#123;<span class="doctag">@link</span> #INFO&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> tag</span><br><span class="line">     *            Used to identify the source of a log message. It usually</span><br><span class="line">     *            identifies the class or activity where the log call occurs.</span><br><span class="line">     * <span class="doctag">@param</span> msg</span><br><span class="line">     *            The message you would like logged.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">i</span><span class="params">(String tag, String msg)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.INFO &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            Log.i(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send a &#123;<span class="doctag">@link</span> #WARN&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> tag</span><br><span class="line">     *            Used to identify the source of a log message. It usually</span><br><span class="line">     *            identifies the class or activity where the log call occurs.</span><br><span class="line">     * <span class="doctag">@param</span> msg</span><br><span class="line">     *            The message you would like logged.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">w</span><span class="params">(String tag, String msg)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.WARN &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            Log.w(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send an &#123;<span class="doctag">@link</span> #ERROR&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> tag</span><br><span class="line">     *            Used to identify the source of a log message. It usually</span><br><span class="line">     *            identifies the class or activity where the log call occurs.</span><br><span class="line">     * <span class="doctag">@param</span> msg</span><br><span class="line">     *            The message you would like logged.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">e</span><span class="params">(String tag, String msg)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.ERROR &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            Log.e(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * What a Terrible Failure: Report a condition that should never happen. The</span><br><span class="line">     * error will always be logged at level ASSERT with the call stack.</span><br><span class="line">     * Depending on system configuration, a report may be added to the</span><br><span class="line">     * &#123;<span class="doctag">@link</span> android.os.DropBoxManager&#125; and/or the process may be terminated</span><br><span class="line">     * immediately with an error dialog.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> tag</span><br><span class="line">     *            Used to identify the source of a log message.</span><br><span class="line">     * <span class="doctag">@param</span> msg</span><br><span class="line">     *            The message you would like logged.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">wtf</span><span class="params">(String tag, String msg)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.ASSERT &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            Log.wtf(tag, msg);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send a &#123;<span class="doctag">@link</span> #VERBOSE&#125; log message. And just print method name and</span><br><span class="line">     * position in black.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">print</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.VERBOSE &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String method = callMethodAndLine();</span><br><span class="line">            Log.v(tag, method);</span><br><span class="line">            <span class="keyword">if</span> (DEBUG_SYSOUT) &#123;</span><br><span class="line">                System.out.println(tag + <span class="string">"  "</span> + method);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send a &#123;<span class="doctag">@link</span> #DEBUG_LEVEL&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> object</span><br><span class="line">     *            The object to print.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">print</span><span class="params">(Object object)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.DEBUG &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String method = callMethodAndLine();</span><br><span class="line">            String content = <span class="string">""</span>;</span><br><span class="line">            <span class="keyword">if</span> (object != <span class="keyword">null</span>) &#123;</span><br><span class="line">                content = object.toString() + <span class="string">"                    ----    "</span></span><br><span class="line">                        + method;</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                content = <span class="string">" ## "</span> + <span class="string">"                ----    "</span> + method;</span><br><span class="line">            &#125;</span><br><span class="line">            Log.d(tag, content);</span><br><span class="line">            <span class="keyword">if</span> (DEBUG_SYSOUT) &#123;</span><br><span class="line">                System.out.println(tag + <span class="string">"  "</span> + content + <span class="string">"  "</span> + method);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Send an &#123;<span class="doctag">@link</span> #ERROR&#125; log message.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> object</span><br><span class="line">     *            The object to print.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">printError</span><span class="params">(Object object)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.ERROR &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String method = callMethodAndLine();</span><br><span class="line">            String content = <span class="string">""</span>;</span><br><span class="line">            <span class="keyword">if</span> (object != <span class="keyword">null</span>) &#123;</span><br><span class="line">                content = object.toString() + <span class="string">"                    ----    "</span></span><br><span class="line">                        + method;</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                content = <span class="string">" ## "</span> + <span class="string">"                    ----    "</span> + method;</span><br><span class="line">            &#125;</span><br><span class="line">            Log.e(tag, content);</span><br><span class="line">            <span class="keyword">if</span> (DEBUG_SYSOUT) &#123;</span><br><span class="line">                System.err.println(tag + <span class="string">"  "</span> + method + <span class="string">"  "</span> + content);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Print the array of stack trace elements of this method in black.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@return</span></span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">printCallHierarchy</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.VERBOSE &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = getClassName();</span><br><span class="line">            String method = callMethodAndLine();</span><br><span class="line">            String hierarchy = getCallHierarchy();</span><br><span class="line">            Log.v(tag, method + hierarchy);</span><br><span class="line">            <span class="keyword">if</span> (DEBUG_SYSOUT) &#123;</span><br><span class="line">                System.out.println(tag + <span class="string">"  "</span> + method + hierarchy);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Print debug log in blue.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@param</span> object</span><br><span class="line">     *            The object to print.</span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">printMyLog</span><span class="params">(Object object)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (Log.DEBUG &gt; DEBUG_LEVEL) &#123;</span><br><span class="line">            String tag = <span class="string">"MYLOG"</span>;</span><br><span class="line">            String method = callMethodAndLine();</span><br><span class="line">            String content = <span class="string">""</span>;</span><br><span class="line">            <span class="keyword">if</span> (object != <span class="keyword">null</span>) &#123;</span><br><span class="line">                content = object.toString() + <span class="string">"                    ----    "</span></span><br><span class="line">                        + method;</span><br><span class="line">            &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">                content = <span class="string">" ## "</span> + <span class="string">"                ----    "</span> + method;</span><br><span class="line">            &#125;</span><br><span class="line">            Log.d(tag, content);</span><br><span class="line">            <span class="keyword">if</span> (DEBUG_SYSOUT) &#123;</span><br><span class="line">                System.out.println(tag + <span class="string">"  "</span> + content + <span class="string">"  "</span> + method);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> String <span class="title">getCallHierarchy</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        String result = <span class="string">""</span>;</span><br><span class="line">        StackTraceElement[] trace = (<span class="keyword">new</span> Exception()).getStackTrace();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">2</span>; i &lt; trace.length; i++) &#123;</span><br><span class="line">            result += <span class="string">"\r\t"</span> + trace[i].getClassName() + <span class="string">"."</span></span><br><span class="line">                    + trace[i].getMethodName() + <span class="string">"():"</span></span><br><span class="line">                    + trace[i].getLineNumber();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> result;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> String <span class="title">getClassName</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        String result = <span class="string">""</span>;</span><br><span class="line">        StackTraceElement thisMethodStack = (<span class="keyword">new</span> Exception()).getStackTrace()[<span class="number">2</span>];</span><br><span class="line">        result = thisMethodStack.getClassName();</span><br><span class="line">        <span class="keyword">return</span> result;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span><br><span class="line">     * Realization of double click jump events.</span><br><span class="line">     * </span><br><span class="line">     * <span class="doctag">@return</span></span><br><span class="line">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> String <span class="title">callMethodAndLine</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        String result = <span class="string">"at "</span>;</span><br><span class="line">        StackTraceElement thisMethodStack = (<span class="keyword">new</span> Exception()).getStackTrace()[<span class="number">2</span>];</span><br><span class="line">        result += thisMethodStack.getClassName() + <span class="string">"."</span>;</span><br><span class="line">        result += thisMethodStack.getMethodName();</span><br><span class="line">        result += <span class="string">"("</span> + thisMethodStack.getFileName();</span><br><span class="line">        result += <span class="string">":"</span> + thisMethodStack.getLineNumber() + <span class="string">")  "</span>;</span><br><span class="line">        <span class="keyword">return</span> result;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p>获取更多请参看我 Github 分享的 Android 工具类库 <a href="https://github.com/jingle1267/android-utils" rel="external nofollow" target="_blank">android-utils</a> 。</p><p><br>本文地址 <a href="http://ihongqiqu.com/2014/10/16/android-log/">http://ihongqiqu.com/2014/10/16/android-log/</a> 作者为<a href="/about/"> Zhenguo</a></p></div><div style="font-size:12px;BORDER-BOTTOM:#bbb 1px solid;BORDER-LEFT:#bbb 1px solid;BACKGROUND:#f6f6f6;MIN-HEIGHT:120px;BORDER-TOP:#bbb 1px solid;BORDER-RIGHT:#bbb 1px solid;MARGIN-LEFT:10px;MARGIN-RIGHT:10px;MARGIN-BOTTOM:10px" class="oec2003right"><div style="MARGIN-TOP:10px;FLOAT:left;MARGIN-LEFT:10px;MARGIN-RIGHT:10px"><img alt="author:Zhenguo" src="http://ihongqiqu.com/imgs/myself.jpg" width="100" height="100"></div><div style="LINE-HEIGHT:200%;MARGIN:10px;COLOR:#000">Author: <a href="http://ihongqiqu.com/">Zhenguo</a> &nbsp&nbsp&nbsp&nbsp Blog: <a href="http://ihongqiqu.com/">http://ihongqiqu.com/</a>&nbsp&nbsp&nbsp&nbsp Email: <a href="mailto:jinzhenguo1990@gmail.com" rel="external nofollow" target="_blank">jinzhenguo1990@gmail.com</a><br>I have almost 5 years of Android application development experience and have a keen interested in the latest emerging technologies. I use my spare time to turn my experience, ideas and love for Android tech into informative articles, tutorials and more in hope to help others and learn more.</div></div><footer class="article-footer clearfix"><div class="article-catetags"><div class="article-tags"><span></span> <a href="/tags/Log/">Log</a></div></div><div class="article-share" id="share"><div data-url="http://ihongqiqu.com/2014/10/16/android-log/" data-title="Android Log工具类 | 爱红旗渠" data-tsina="undefined" class="share clearfix"></div></div></footer></article><nav class="article-nav clearfix"><div class="prev"><a href="/2014/10/19/inversion-of-control/" title="IOC原理"><strong>上一篇：</strong><br><span>IOC原理</span></a></div><div class="next"><a href="/2014/10/15/android-ui-optimize/" title="Android UI优化策略"><strong>下一篇：</strong><br><span>Android UI优化策略</span></a></div></nav><section id="comments" class="comment"><div class="ds-thread" data-thread-key="2014/10/16/android-log/" data-title="Android Log工具类" data-url="http://ihongqiqu.com/2014/10/16/android-log/"></div></section></div><div class="openaside"><a class="navbutton" href="#" title="显示侧边栏"></a></div><div id="toc" class="toc-aside"><strong class="toc-title">文章目录</strong><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#u6982_u8981"><span class="toc-number">1.</span> <span class="toc-text">概要</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#u51CF_u5C11_u4E00_u4E2A_Log__u53C2_u6570"><span class="toc-number">2.</span> <span class="toc-text">减少一个 Log 参数</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#u8DF3_u8F6C_u5230_u6E90_u4EE3_u7801_Log__u8C03_u7528_u5904"><span class="toc-number">3.</span> <span class="toc-text">跳转到源代码 Log 调用处</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#u5C4F_u853D_u6240_u6709_Log"><span class="toc-number">4.</span> <span class="toc-text">屏蔽所有 Log</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#u4F7F_u7528_u65B9_u6CD5"><span class="toc-number">5.</span> <span class="toc-text">使用方法</span></a></li></ol></div><div id="asidepart"><div class="closeaside"><a class="closebutton" href="#" title="隐藏侧边栏"></a></div><aside class="clearfix"><div class="github-card"><p class="asidetitle">Github 名片</p><div class="github-card" data-github="jingle1267" data-width="220" data-height="119" data-theme="medium"><script type="text/javascript" src="//cdn.jsdelivr.net/github-cards/latest/widget.js"></script></div></div><div class="categorieslist"><p class="asidetitle">分类</p><ul><li><a href="/categories/Android-DataBinding/" title="Android DataBinding">Android DataBinding<sup>3</sup></a></li><li><a href="/categories/Android不规则图形专题/" title="Android不规则图形专题">Android不规则图形专题<sup>4</sup></a></li><li><a href="/categories/Android打多渠道包/" title="Android打多渠道包">Android打多渠道包<sup>3</sup></a></li><li><a href="/categories/Android测试/" title="Android测试">Android测试<sup>4</sup></a></li><li><a href="/categories/H5唤起原生应用/" title="H5唤起原生应用">H5唤起原生应用<sup>2</sup></a></li><li><a href="/categories/Seo优化/" title="Seo优化">Seo优化<sup>1</sup></a></li><li><a href="/categories/hexo/" title="hexo">hexo<sup>1</sup></a></li><li><a href="/categories/网络爬虫/" title="网络爬虫">网络爬虫<sup>2</sup></a></li><li><a href="/categories/设计模式/" title="设计模式">设计模式<sup>24</sup></a></li><li><a href="/categories/需求/" title="需求">需求<sup>1</sup></a></li></ul></div><div class="tagcloudlist"><p class="asidetitle">标签云</p><div class="tagcloudlist clearfix"><a href="/tags/Android-DataBinding/" style="font-size:16.67px">Android DataBinding</a> <a href="/tags/Android优化/" style="font-size:10px">Android优化</a> <a href="/tags/App-Links/" style="font-size:10px">App Links</a> <a href="/tags/Git/" style="font-size:10px">Git</a> <a href="/tags/IOC/" style="font-size:10px">IOC</a> <a href="/tags/Log/" style="font-size:10px">Log</a> <a href="/tags/Monkey/" style="font-size:10px">Monkey</a> <a href="/tags/Seo优化/" style="font-size:10px">Seo优化</a> <a href="/tags/cnblogs/" style="font-size:10px">cnblogs</a> <a href="/tags/hexo/" style="font-size:10px">hexo</a> <a href="/tags/instrumentation/" style="font-size:10px">instrumentation</a> <a href="/tags/monkeyrunner/" style="font-size:10px">monkeyrunner</a> <a href="/tags/唤起/" style="font-size:10px">唤起</a> <a href="/tags/开会/" style="font-size:10px">开会</a> <a href="/tags/影响力/" style="font-size:10px">影响力</a> <a href="/tags/心理学/" style="font-size:10px">心理学</a> <a href="/tags/打包/" style="font-size:16.67px">打包</a> <a href="/tags/收集需求/" style="font-size:10px">收集需求</a> <a href="/tags/敏捷/" style="font-size:10px">敏捷</a> <a href="/tags/权限/" style="font-size:10px">权限</a> <a href="/tags/网络爬虫/" style="font-size:13.33px">网络爬虫</a> <a href="/tags/行为面谈/" style="font-size:10px">行为面谈</a> <a href="/tags/设计模式/" style="font-size:20px">设计模式</a> <a href="/tags/说服他人/" style="font-size:10px">说服他人</a></div></div><div class="archiveslist"><p class="asidetitle"><a href="/archives">归档</a></p><ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/11/">十一月 2016</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/">十月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">九月 2016</a><span class="archive-list-count">8</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/05/">五月 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">四月 2016</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">三月 2016</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">一月 2016</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">十二月 2015</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/07/">七月 2015</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/05/">五月 2015</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/12/">十二月 2014</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/11/">十一月 2014</a><span class="archive-list-count">12</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/10/">十月 2014</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/09/">九月 2014</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/08/">八月 2014</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/07/">七月 2014</a><span class="archive-list-count">5</span></li></ul></div><div class="hotarticles"><p class="asidetitle">热评文章</p><div class="ds-top-threads" data-range="monthly" data-num-items="5"></div></div><div class="linkslist"><p class="asidetitle">友情链接</p><ul><li><a href="http://www.cnblogs.com/jingle1267/" target="_blank" title="博客园爱红旗渠">博客园</a></li><li><a href="http://blog.csdn.net/m925986445" target="_blank" title="CSDN爱红旗渠">CSDN博客</a></li><li><a href="http://www.hostodo.cn/" target="_blank" title="年付低至10美元洛杉矶VPS主机" rel="external nofollow">Hostodo</a></li><li><a href="http://www.80iter.com/" target="_blank" title="八零IT人" rel="external nofollow">八零IT人</a></li><li><a href="http://salogs.com/" target="_blank" title="拥抱开源，分享经验!" rel="external nofollow">SA-Logs</a></li></ul></div><div class="rsspart"><a href="/atom.xml" target="_blank" title="rss">RSS 订阅</a></div></aside></div></div><footer><div id="footer"><div class="line"><span></span><div class="author"></div></div><section class="info"><p>生活不止眼前的苟且<br>还有诗和远方的田野</p></section><div class="social-font"><a href="https://github.com/jingle1267" target="_blank" class="icon-github" title="github" rel="external nofollow"></a> <a href="mailto:jingle1267@163.com" target="_blank" class="icon-email" title="Email Me" rel="external nofollow"></a></div><p class="copyright">Copyright ©2014-2016 <a href="/about" target="_blank" title="Jin">Jin</a></p></div><script type="text/javascript">var cnzz_protocol="https:"==document.location.protocol?" https://":" http://";document.write(unescape("%3Cspan style='display:none;' id='cnzz_stat_icon_1260545070'%3E%3C/span%3E%3Cscript src='"+cnzz_protocol+"s95.cnzz.com/z_stat.php%3Fid%3D1260545070' type='text/javascript'%3E%3C/script%3E"))</script><script type="text/javascript">!function(t,e,n,s,c,i,a){t.SwiftypeObject=c,t[c]=t[c]||function(){(t[c].q=t[c].q||[]).push(arguments)},i=e.createElement(n),a=e.getElementsByTagName(n)[0],i.async=1,i.src=s,a.parentNode.insertBefore(i,a)}(window,document,"script","//s.swiftypecdn.com/install/v2/st.js","_st"),_st("install","qFtymqNnfXjgmwxAJxMP","2.0.0")</script></footer><script src="/js/jquery-2.0.3.min.js"></script><script src="/js/jquery.imagesloaded.min.js"></script><script src="/js/gallery.js"></script><script src="/js/jquery.qrcode-0.12.0.min.js"></script><script type="text/javascript">$(document).ready(function(){function e(){"number"==typeof window.innerWidth?n=window.innerWidth:document.documentElement&&document.documentElement.clientWidth&&(n=document.documentElement.clientWidth)}$(".navbar").click(function(){$("header nav").toggleClass("shownav")});var n=0,s=$("#main"),a=$("#asidepart"),o=$(".closeaside"),d=$(".openaside");o.click(function(){a.addClass("fadeOut").css("display","none"),d.css("display","block").addClass("fadeIn"),s.addClass("moveMain")}),d.click(function(){d.css("display","none").removeClass("beforeFadeIn"),a.css("display","block").removeClass("fadeOut").addClass("fadeIn"),s.removeClass("moveMain")}),$(window).scroll(function(){d.css("top",Math.max(80,260-$(this).scrollTop()))}),$(window).resize(function(){e(),n>=1024?$("header nav").removeClass("shownav"):(s.removeClass("moveMain"),a.css("display","block").removeClass("fadeOut"),d.css("display","none"),$("#toc.toc-aside").css("display","none"))})})</script><script type="text/javascript">$(document).ready(function(){var c=$(".article-content>iframe"),n=$(".article-content>embed"),o=($("#toc"),$("#toc.toc-aside")),e=$(".openaside"),i=$(".closeaside");c.length>0&&c.wrap('<div class="video-container" />'),n.length>0&&n.wrap('<div class="video-container" />'),i.click(function(){o.css("display","block").addClass("fadeIn")}),e.click(function(){o.css("display","none")}),$(window).scroll(function(){o.css("top",Math.max(140,320-$(this).scrollTop()))})})</script><script type="text/javascript">$(document).ready(function(){function e(){"number"==typeof window.innerWidth?n=window.innerWidth:document.documentElement&&document.documentElement.clientWidth&&(n=document.documentElement.clientWidth);var e=n>1024?200:100,t={render:"image",size:e,fill:"#2ca6cb",text:r,radius:.5,quiet:1},a=$(".article-share-qrcode").position();$(".hoverqrcode").empty().css("width",e).css("height",e).css("left",a.left-e/2+20).css("top",a.top-e-10).qrcode(t)}var t=$(".share"),r=t.attr("data-url"),a=encodeURIComponent(r),i=t.attr("data-title"),c=t.attr("data-tsina"),o=(t.attr("description"),['<div class="hoverqrcode clearfix"></div>','<a class="overlay" id="qrcode"></a>','<a href="https://www.facebook.com/sharer.php?u='+a+'" class="article-share-facebook" target="_blank" title="Facebook"></a>','<a href="https://twitter.com/intent/tweet?url='+a+'" class="article-share-twitter" target="_blank" title="Twitter"></a>','<a href="#qrcode" class="article-share-qrcode" title="微信"></a>','<a href="http://widget.renren.com/dialog/share?resourceUrl='+a+"&srcUrl="+a+"&title="+i+'" class="article-share-renren" target="_blank" title="人人"></a>','<a href="http://service.weibo.com/share/share.php?title='+i+"&url="+a+"&ralateUid="+c+'&searchPic=true&style=number" class="article-share-weibo" target="_blank" title="微博"></a>','<span title="Share to"></span>'].join(""));t.append(o),$(".hoverqrcode").hide();var n=0;$(window).resize(function(){$(".hoverqrcode").hide()}),$(".article-share-qrcode").click(function(){e(),$(".hoverqrcode").toggle()}),$(".article-share-qrcode").hover(function(){},function(){$(".hoverqrcode").hide()})})</script><script type="text/javascript">var duoshuoQuery={short_name:"ihongqiqu"};!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="//static.duoshuo.com/embed.js",e.charset="UTF-8",(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(e)}()</script><link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css"><script src="/fancybox/jquery.fancybox.pack.js"></script><script type="text/javascript">$(document).ready(function(){$(".article-content").each(function(a){$(this).find("img").each(function(){if(!$(this).parent().hasClass("fancybox")){var a=this.alt;a&&$(this).after('<span class="caption">'+a+"</span>"),$(this).wrap('<a href="'+this.src+'" title="'+a+'" class="fancybox"></a>')}}),$(this).find(".fancybox").each(function(){$(this).attr("rel","article"+a)})}),$.fancybox&&$(".fancybox").fancybox()})</script><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="//hm.baidu.com/hm.js?9223f49a80da70c70261ac4e2f74af9a";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}()</script><script type="text/javascript">var cnzz_protocol="https:"==document.location.protocol?" https://":" http://";document.write(unescape("%3Cspan id='cnzz_stat_icon_null'%3E%3C/span%3E%3Cscript src='"+cnzz_protocol+"s23.cnzz.com/z_stat.php%3Fid%3Dnull' type='text/javascript'%3E%3C/script%3E"))</script><div id="totop"><a title="返回顶部"><img alt="返回顶部" src="/img/scrollup.png"></a></div><script src="/js/totop.js"></script></body><!-- rebuild by neat -->